<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import adminPermissions from '@/api/user/adminPermissions'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'
import dictHelp from "@/utils/dicthelp.js";
const crudRef = ref()

const options = reactive({
  id: 'admin_permissions',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'drawer',
    width: 600
  },
  api: adminPermissions.list,
  isExpand: true,
  add: {
    show: true,
    api: adminPermissions.save,
    auth: ['user:adminPermissions:save']
  },
  edit: {
    show: true,
    api: adminPermissions.update,
    auth: ['user:adminPermissions:update']
  },
  delete: {
    show: true,
    api: adminPermissions.deletes,
    auth: ['user:adminPermissions:delete']
  }
})

const columns = reactive([
  {
    title: "",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "上级",
    dataIndex: "parent_id",
    formType: "tree-select",
    hide: true,
    addDefaultValue:0,
    dict:dictHelp.clientPermissions
  },
  {
    title: "名称",
    dataIndex: "name",
    formType: "input",
    // hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "标识",
    dataIndex: "slug",
    formType: "input",
    // hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "路由",
    dataIndex: "http_path",
    formType: "input",
    // hide: true
  },
  {
    title: "排序",
    dataIndex: "custom_order",
    formType: "input",
    // search: true,
  },
  {
    title: "模板路径",
    dataIndex: "template",
    formType: "input",
  },
  {
    title: "图标",
    dataIndex: "icon",
    formType: "input",
  },
  {
    title: "状态",
    dataIndex: "status",
    formType: "switch",
    checkedValue: 1,
  },
  {
    title: "类型",
    dataIndex: "type",
    formType: "radio",
    addDefaultValue: 1,
    dict:{
      data:[
        {
          label: "菜单",
          value: 1
        },
        {
          label: "按钮",
          value: 2
        }
      ],
      translation: true
    }
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  }
])
</script>
<script> export default { name: 'user:adminPermissions' } </script>